//
//  RootCollectionViewCell.m
//  shanHaiHuiApp
//
//  Created by DS on 2018/3/6.
//  Copyright © 2018年 徐双. All rights reserved.
//

#import "RootCollectionViewCell.h"

@interface RootCollectionViewCell ()

Strong UIImageView *titleImageView;
Strong UILabel *titleLabel;

@end

@implementation RootCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        _titleImageView = [UIImageView new];
        
        _titleLabel  = [[UILabel alloc]init];
        _titleLabel.font = DEF_FontSize_12;
        _titleLabel.textColor = getColor(textColor);
        _titleLabel.adjustsFontSizeToFitWidth = YES;
        _titleLabel.textAlignment = NSTextAlignmentCenter;
        [self.contentView sd_addSubviews:@[_titleLabel , _titleImageView]];
    }
    return self;
}

- (void)layoutSubviews{
    [super layoutSubviews];
    self.titleImageView.frame = CGRectMake((self.width - UNIT_WIDTH(60)) / 2,  UNIT_WIDTH(13), UNIT_WIDTH(60),UNIT_WIDTH(60));
    self.titleLabel.frame = CGRectMake(0, CGRectGetMaxY(self.titleImageView.frame), self.width, self.height - CGRectGetMaxY(self.titleImageView.frame));
}

//- (void)setModel:(NSDictionary *)model{
//    _model = model;
//    self.titleLabel.text = model[@"title"];
//    self.titleImageView.image = [UIImage imageNamed:model[@"image"]];
//}

- (void)setModel:(CollectModel *)model{
    _model = model;
    self.titleLabel.text = model.fDesc;
    [self.titleImageView sd_setImageWithURL:[NSURL URLWithString:model.shImagepfilename] placeholderImage:[UIImage imageNamed:@"shanhaihuilogo"]];
}

@end
